package com.eastfair.config.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 
 * </p>
 *
 * @author zjn
 * @date 2022-03-25
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "FormFieldFieldGroupEnum", description = "表单分组类型 #{PERSONAL:个人;COMPANY:公司;GENNERAL:总部;FILE:文件;TAG:标签;EXHIBITOR_PRODUCT:展品-枚举")
public enum FormFieldFieldGroupEnum implements BaseEnum {

    /**
     * PERSONAL="个人"
     */
    PERSONAL("个人"),
    /**
     * COMPANY="公司"
     */
    COMPANY("公司"),
    /**
     * GENNERAL="总部"
     */
    GENNERAL("总部"),
    /**
     * FILE="文件"
     */
    FILE("文件"),
    /**
     * TAG="标签"
     */
    TAG("标签"),
    /**
     * EXHIBITOR_PRODUCT="展品"
     */
    EXHIBITOR_PRODUCT("展品"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static FormFieldFieldGroupEnum match(String val, FormFieldFieldGroupEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static FormFieldFieldGroupEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(FormFieldFieldGroupEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "PERSONAL,COMPANY,GENNERAL,FILE,TAG,EXHIBITOR_PRODUCT", example = "PERSONAL")
    public String getCode() {
        return this.name();
    }

}
